﻿using System;
using System . Collections . Generic;
using System . Linq;
using System . Text;
using System . Threading . Tasks;
using System . Xml . Linq;

namespace GameClassLibrary . Maps
{
    /// <summary>
    /// 代表地图上的元素
    /// </summary>
    public abstract class MapObject : GameObject
    {
        /// <summary>
        /// 元素的起始X值
        /// </summary>
        public long X { get; set; }

        /// <summary>
        /// 元素的起始Y值
        /// </summary>
        public long Y { get; set; }

        /// <summary>
        /// 元素的尺寸
        /// </summary>
        public virtual SizeOfMapObject Size { get;  set; }

        public abstract void UpdateView ( );

        public MapObject ( XElement saving ) : base ( saving )
        {

            X = ( long ) saving . Attribute ( "X" );
            Y = ( long ) saving . Attribute ( "Y" );
            Size = ( SizeOfMapObject ) Enum . Parse ( typeof ( SizeOfMapObject ) , ( string ) saving . Attribute ( "Size" ) , true );
        }


        public override XElement Save ( )
        {
            var temp= base . Save ( );
            temp . SetAttributeValue ( "X" , X );
            temp . SetAttributeValue ( "Y" , Y );
            temp . SetAttributeValue ( "Size" , Size );
            return temp;
        }

    }
}
